package d0325;

import java.time.LocalDate;
import java.time.LocalDateTime;

public class TestLocalDate {
    public static void main(String[] args) {
        LocalDate date1=LocalDate.now();
        System.out.println(date1);

        LocalDate date2=LocalDate.of(2021,5,21);
        System.out.println(date2);

        System.out.println(date2.getYear());
        System.out.println(date2.getMonth());

        String str="2022-09-12";
        LocalDate date3=LocalDate.parse(str);
        System.out.println(date3);
        System.out.println();

        System.out.println("====================================");

        //用当前日期生成LocalDateTime
        LocalDateTime dT1=LocalDateTime.now();
        LocalDateTime dT2=LocalDateTime.of(2020, 12, 9,12,23,4);
        System.out.println(dT1);
        //返回各字段值
        System.out.println(dT2);
        //将字符串转换
        String str2="2020-12-12T12:34:09";
        LocalDateTime dT3=LocalDateTime.parse(str2);
        System.out.println(dT3);
    }
}
